package com.ruoyi.culture.service;

import com.ruoyi.culture.constant.ActivityType;
import com.ruoyi.culture.domain.CreativePublish;
import com.ruoyi.culture.mapper.CreativePublishMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;
import java.util.Date;
import java.util.List;

import static com.ruoyi.culture.constant.ActivityType.EXHIBITION;

@Service
public class CreativePublishService {

    @Autowired
    CreativePublishMapper creativePublishMapper;

    public void insert(CreativePublish creativePublish) {
        int addResult = creativePublishMapper.addOne(creativePublish);
        if (addResult == 0) {
            throw new RuntimeException("新增信息发布失败");
        }
    }

    public List<CreativePublish> list(String title, int categoryId, int labelId, Date beginningDate, Date endingDate) {
        List<CreativePublish> list = creativePublishMapper.list(title, categoryId, labelId, beginningDate, endingDate);
        return list;
    }

    public void update(CreativePublish creativePublish) {
        int updateResult = creativePublishMapper.update(creativePublish);
        if (updateResult == 0) {
            throw new RuntimeException("更新发布的信息失败");
        }
    }

    public void delete(int id) {
        int deleteResult = creativePublishMapper.delete(id);
        if (deleteResult == 0) {
            throw new RuntimeException("删除发布的信息失败");
        }
    }
}
